package com.xhs.controller;

import com.xhs.dto.request.AddEventParams;
import com.xhs.dto.request.AddLowCodeUrlParams;
import com.xhs.dto.request.FindLowCodeUrlParams;
import com.xhs.dto.request.PageEventParams;
import com.xhs.message.ReturnResult;
import com.xhs.service.MongoService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @desc:
 * @projectName: springboot-mongodb
 * @author: xhs
 * @date: 2024-1-6 006 21:31
 * @version: JDK 1.8
 */
@RestController
@RequestMapping("/mongo")
public class MongoController {

    @Resource
    private MongoService mongoService;

    /**
     * 查询所有用户
     *
     * @return ReturnResult<Object>
     */
    @GetMapping("/getUser")
    public ReturnResult<Object> getUser() {
        return mongoService.getUser();
    }

    /**
     * 条件查询 LowCodeUrl
     *
     * @param findLowCodeUrlParams 查询条件
     * @return ReturnResult<Object>
     */
    @PostMapping("/getLowCodeUrl")
    public ReturnResult<Object> getLowCodeUrl(@RequestBody FindLowCodeUrlParams findLowCodeUrlParams) {
        return mongoService.getLowCodeUrl(findLowCodeUrlParams);
    }

    /**
     * 新增 LowCodeUrl 数据
     *
     * @param lowCodeUrlParams LowCodeUrl 数据
     * @return ReturnResult<Object>
     */
    @PostMapping("/addLowCodeUrl")
    public ReturnResult<Object> addLowCodeUrl(@Validated @RequestBody AddLowCodeUrlParams lowCodeUrlParams) {
        return mongoService.addLowCodeUrl(lowCodeUrlParams);
    }

    /**
     * 新增 event 数据
     *
     * @param eventParams LowCodeUrl 数据
     * @return ReturnResult<Object>
     */
    @PostMapping("/addEvent")
    public ReturnResult<Object> addEvent(@Validated @RequestBody AddEventParams eventParams) {
        return mongoService.addEvent(eventParams);
    }

    /**
     * 分页查询 event 数据
     *
     * @param eventParams 查询条件
     * @return ReturnResult<Object>
     */
    @PostMapping("/pageEvent")
    public ReturnResult<Object> pageEvent(@Validated @RequestBody PageEventParams eventParams) {
        return mongoService.pageEvent(eventParams);
    }
}
